package com.chinairi.mall.controller;


import com.chinairi.common.utils.ResponseUtil;
import com.chinairi.mall.controller.viewobject.TCVO;
import com.chinairi.mall.model.TrackConfig;
import com.chinairi.mall.service.ITrackConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.chinairi.common.controller.BaseController;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 节点带物料类别配置表 前端控制器
 * </p>
 *
 * @author Webgasd
 * @since 2020-08-17
 */
@RestController
@RequestMapping("/track-config")
public class TrackConfigController extends BaseController {

    private static final long serialVersionUID = -6687407896761950622L;

    @Autowired
    private ITrackConfigService iTrackConfigService;

    @PostMapping("/config")
    @ResponseBody
    public void config(TCVO tcvo) throws IOException {
        iTrackConfigService.addPoint(tcvo);
        ResponseUtil.showMessage("success","配置成功", null);
    }

    @PutMapping("/update")
    @ResponseBody
    public void update(TCVO tcvo) throws IOException {
        iTrackConfigService.updatePoint(tcvo);
        ResponseUtil.showMessage("success","更新成功", null);
    }

    @DeleteMapping("/delete")
    @ResponseBody
    public void delete(TCVO tcvo) throws IOException {
        iTrackConfigService.deletePoint(tcvo.getTrackNumber());
        ResponseUtil.showMessage("success","删除成功!", null);
    }

    @GetMapping("/get")
    @ResponseBody
    public void getList(TCVO tcvo) throws IOException {
        List<TrackConfig> list =iTrackConfigService.getPoints(tcvo);
        ResponseUtil.showMessage("success","节点列表", list);
    }
}
